// serveice统一出口
// 封装案例

import HttpRequest from './request'
import { BASE_URL, TIME_OUT } from './request/config'

const httpRequest = new HttpRequest({
  baseURL: BASE_URL,
  timeout: TIME_OUT,
  interceptors: {
    requestInterceptor: (config:any) => {
      const token =sessionStorage.getItem('token');

      if (token) {
        config.headers.Authorization =token;
      
      }

      console.log('请求成功')
       return config
    },
    requestInterceptorCatch: (err) => {
      console.log('请求失败')
      return err
    },
    responseInterceptor: (res) => {
      console.log('响应成功')
      return res
    },
    responseInterceptorCatch: (err) => {
      console.log('响应失败')
      return err
    }
  }
})
export default httpRequest
